package com.xb.loan.util.binaryConvert;


import com.xb.loan.util.binaryConvert.config.ParseConfigManager;
import com.xb.loan.util.binaryConvert.config.ParseType;
import com.xb.loan.util.binaryConvert.parse.ParseAble;
import com.xb.loan.util.binaryConvert.parse.ParsePointer;

public class BinaryParseUtil {
	
	@SuppressWarnings("unchecked")
	private static ParseAble parser = ParseConfigManager.getParser(ParseType.STRUCT);
	
	@SuppressWarnings("unchecked")
	public static byte[] format(Object obj){
		
		return parser.format(obj, null);
	}
	
	@SuppressWarnings("unchecked")
	public static <T> T convert(byte[] data,Class<T> clazz){
		
		return (T) parser.convert(data, new ParsePointer(0), clazz, null);
		
		
	}
}
